package com.cnswhy.cloud.server.core.channel.aliyun;

import com.alibaba.fastjson.JSON;
import com.aliyun.iot20180120.models.QueryProductListResponse;
import com.aliyun.teaopenapi.models.Config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class AliyunIotService {
    public static com.aliyun.iot20180120.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        Config config = new Config()
                // 您的AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 您的AccessKey Secret
                .setAccessKeySecret(accessKeySecret);
        // 访问的域名
        config.endpoint = "iot.cn-shanghai.aliyuncs.com";
        return new com.aliyun.iot20180120.Client(config);
    }
    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.iot20180120.Client client = createClient("LTAIlBFDDNv8oSjE", "BwRCJaY2QwAFDkSG5twZhJkp3FQNjr");
        com.aliyun.iot20180120.models.QueryProductListRequest queryProductListRequest = new com.aliyun.iot20180120.models.QueryProductListRequest()
                .setIotInstanceId("iot-060a037q")
                .setPageSize(1)
                .setCurrentPage(1);
        QueryProductListResponse queryProductListResponse = client.queryProductList(queryProductListRequest);
        log.info(JSON.toJSONString(queryProductListResponse));

    }
}
